<?php
    /**
     * Created by PhpStorm.
     * User: huangzhongwei
     * Date: 2018/11/7
     * Time: 19:31
     */

    namespace app\api\service;


    class GoodsType
    {
        public function toCascader($university){

            $cascader=[];
            $i=0;
            foreach ($university as $key => $value) {

                if (count($value['goods_type']) == 0) {

                    continue;
                }
                $cascader[$i]['value'] = $value['id'];

                $cascader[$i]['label'] = $value['university'];

                foreach ($value['goods_type'] as $key1 => $val) {
                    $cascader[$i]['children'][$key1]['value'] = $val['id'];
                    $cascader[$i]['children'][$key1]['label'] = $val['goods_type'];
                }
                $i++;
            }

            return $cascader;

        }

    }